﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.flashsale.ui {
    import flash.display.*;
    import flash.utils.*;
    import org.aswing.*;
    import Classes.*;
    import Classes.util.*;
    import org.aswing.geom.*;
    import Display.*;
    import org.aswing.ext.*;
    import Display.aswingui.*;

    public class PackageSaleCell extends JPanel implements GridListCell {

        protected var m_assets:Dictionary;
        protected var m_cellValue:Object;

        public function PackageSaleCell(){
            super(new BorderLayout());
        }
        public static function get CELL_WIDTH():int{
            return (239);
        }
        public static function get CELL_HEIGHT():int{
            return (187);
        }

        protected function get CELL_BG_CLASS():String{
            return ("dialog_flashSale_packageSaleCard");
        }
        protected function get HEADING_FONTSIZE():int{
            return (18);
        }
        protected function get HEADING_BOTTOM_PAD():int{
            return (5);
        }
        protected function get BODYA_FONTSIZE():int{
            return (38);
        }
        protected function get BODYB_FONTSIZE():int{
            return (16);
        }
        protected function get BODYC_FONTSIZE():int{
            return (24);
        }
        protected function get BODY_BOTTOM_PAD():int{
            return (10);
        }
        public function get optionNum():int{
            return ((this.m_cellValue.index + 1));
        }
        public function get type():String{
            return (this.m_cellValue.type);
        }
        public function get amount():int{
            return (this.m_cellValue.amount);
        }
        public function get baseCost():int{
            return (this.m_cellValue.baseCostUSD);
        }
        public function get discount():int{
            return (this.m_cellValue.discount);
        }
        public function get discountCost():int{
            return ((this.m_cellValue.baseCostUSD * (1 - (this.m_cellValue.discount / 100))));
        }
        public function get purchaseCallback():Function{
            return (this.m_cellValue.callback);
        }
        public function setGridListCellStatus(_arg1:GridList, _arg2:Boolean, _arg3:int):void{
        }
        public function setCellValue(_arg1):void{
            this.m_cellValue = _arg1;
            Global.delayedAssets.get(DelayedAssetLoader.FLASHSALE_ASSETS, this.onAssetsLoaded);
        }
        public function getCellValue(){
            return (this.m_cellValue);
        }
        public function getCellComponent():Component{
            return (this);
        }
        protected function onAssetsLoaded(_arg1:DisplayObject, _arg2:String=""):void{
            var _local3:Object = (_arg1 as Object);
            this.m_assets = new Dictionary(false);
            this.m_assets["bg"] = (new (_local3[this.CELL_BG_CLASS])() as DisplayObject);
            this.m_assets["icon_cash"] = (new _local3.icon_cash_small() as DisplayObject);
            this.m_assets["icon_coins"] = (new _local3.icon_coins_small() as DisplayObject);
            this.buildCell();
        }
        protected function makeBackground():void{
            var _local1:DisplayObject = this.m_assets["bg"];
            var _local2:MarginBackground = new MarginBackground(_local1, new Insets(0, 0, 10, 0));
            this.setBackgroundDecorator(_local2);
            this.setPreferredSize(new IntDimension(_local1.width, _local1.height));
            this.setMinimumSize(new IntDimension(_local1.width, _local1.height));
            this.setMaximumSize(new IntDimension(_local1.width, _local1.height));
        }
        protected function buildCell():void{
            this.makeBackground();
            this.append(this.createHeaderPanel(), BorderLayout.NORTH);
            this.append(this.createBodyPanel(), BorderLayout.CENTER);
            this.append(this.createFooterPanel(), BorderLayout.SOUTH);
            ASwingHelper.prepare(this);
        }
        protected function createHeaderPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            ASwingHelper.setEasyBorder(_local1, 0, 0, this.HEADING_BOTTOM_PAD, 0);
            var _local2:String = TextFieldUtil.formatSmallCapsString(ZLoc.t("Dialogs", "FlashSale_PackageCell_heading1", {num:this.optionNum}));
            var _local3:JLabel = ASwingHelper.makeLabel(_local2, EmbeddedArt.TITLE_FONT, this.HEADING_FONTSIZE, EmbeddedArt.blueTextColor);
            _local1.append(_local3);
            return (_local1);
        }
        protected function createBodyPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            var _local3:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local4:JPanel = ASwingHelper.makeSoftBoxJPanelVertical(SoftBoxLayout.TOP);
            ASwingHelper.setEasyBorder(_local1, 0, 0, this.BODY_BOTTOM_PAD, 0);
            var _local5:String = this.amount.toString();
            var _local6:String = ZLoc.t("Dialogs", "FlashSale_PackageCell_body1", {cost:this.baseCost});
            var _local7:String = TextFieldUtil.formatSmallCapsString(ZLoc.t("Dialogs", "FlashSale_PackageCell_body2", {cost:this.discountCost}));
            var _local8:DisplayObject = ((this.type)=="cash") ? this.m_assets["icon_cash"] : this.m_assets["icon_coins"];
            var _local9:int = ((this.type)!="cash") ? 8 : 5;
            var _local10:JTextField = ASwingHelper.makeTextField(_local5, EmbeddedArt.TITLE_FONT, this.BODYA_FONTSIZE, EmbeddedArt.yellowTextColor, 0);
            var _local11:JLabel = ASwingHelper.makeLabel(_local6, EmbeddedArt.DEFAULT_FONT_NAME_BOLD, this.BODYB_FONTSIZE, EmbeddedArt.darkBrownTextColor);
            var _local12:JLabel = ASwingHelper.makeLabel(_local7, EmbeddedArt.TITLE_FONT, this.BODYC_FONTSIZE, EmbeddedArt.blueTextColor);
            var _local13:AssetPane = new AssetPane(_local8);
            _local10.filters = EmbeddedArt.newtitleFilters;
            _local4.appendAll(ASwingHelper.verticalStrut(8), _local13);
            _local3.appendAll(_local4, _local10);
            _local2.appendAll(_local3, ASwingHelper.verticalStrut(-10), _local11, ASwingHelper.verticalStrut(_local9), _local12);
            _local1.append(_local2);
            return (_local1);
        }
        protected function createFooterPanel():JPanel{
            var _local1:JPanel = ASwingHelper.makeSoftBoxJPanel(SoftBoxLayout.CENTER);
            var _local2:String = ZLoc.t("Dialogs", "Purchase");
            var _local3:CustomButton = new CustomButton(_local2, null, "GreenButtonUI");
            _local3.addActionListener(this.purchaseCallback, 0, false);
            _local1.append(_local3);
            return (_local1);
        }

    }
}//package Modules.flashsale.ui 
